<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/layui/css/layui.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/static/css/adminLogin.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/resources/layui/layui.js"></script>
</head>
<body>
<div class="wrap">
    <img src="${pageContext.request.contextPath}/resources/static/image/img5.jpg" class="imgStyle">
    <div class="loginForm">
        <form id="fom" action="${pageContext.request.contextPath}/login.go?service=login" method="post">
            <div class="logoHead" style="text-align: center">
                <p style="font-weight: bold;font-size: 28px;margin-left: -15px;color: dimgray">CMS客户管理系统</p>
            </div>
            <div class="usernameWrapDiv">
                <div class="usernameLabel">
                    <label>用户名:</label>
                </div>
                <div class="usernameDiv">
                    <i class="layui-icon layui-icon-username adminIcon"></i>
                    <input id="loginUsername" class="layui-input adminInput" type="text" name="username" placeholder="输入用户名" >
                </div>
            </div>
            <div class="usernameWrapDiv">
                <div class="usernameLabel">
                    <label>密码:</label>
                </div>
                <div class="passwordDiv">
                    <i class="layui-icon layui-icon-password adminIcon"></i>
                    <input id="loginPassword" class="layui-input adminInput" type="password" name="password" placeholder="输入密码">
                </div>
            </div>
            <div class="usernameWrapDiv">
                <div class="usernameLabel">
                    <label>验证码:</label>
                </div>
                <div class="cardDiv">
                    <input id="loginCard" class="layui-input cardInput" type="text" name="card" placeholder="输入验证码">
                </div>
                <div class="codeDiv">
                    <input id="loginCode" class="layui-input codeInput"  type="button" value="0000">
                </div>
            </div>
            <div class="usernameWrapDiv">
                <div class="submitLabel">
                    <label class="codeInput" style="color: red;">${respData}</label>
                    <%--<label>没有账号？<a href="#" id="loginRegister">点击注册</a></label>--%>
                </div>
                <div class="submitDiv">
                    <input id="loginBtn" type="button" class="submit layui-btn layui-btn-primary" value="登录"></input>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    layui.use(['jquery'],function () {
        var $ = layui.jquery;
        window.onload = function () {
            $("#loginCode").click()
        }
        var urlHead = "${pageContext.request.contextPath}";
        $("#loginCode").click(function () {
            var obj = $("#loginCode");
            var xhr = new XMLHttpRequest(); //创建通信对象
            xhr.onreadystatechange = function () {
                if(xhr.readyState == 4 && xhr.status == 200){
                    var jsonObj = eval('('+xhr.responseText+')');
                    obj.val(jsonObj["data"]);
                }
            };
            xhr.open("GET",urlHead+"/checkCode.do",true);
            xhr.send();
        });

        $("#loginBtn").click(function () {
            $("#fom").submit();
        })
    })
</script>
</html>
